//
//  RegisterView_FieldView.m
//  liBaQiang
//
//  Created by 奇林刘 on 2018/10/19.
//  Copyright © 2018年 liu. All rights reserved.
//

#import "RegisterView_FieldView.h"

@interface RegisterView_FieldView ()

@property (nonatomic, strong) UIView *lineTop;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UITextField *textField;
@property (nonatomic, strong) UIView *lineBottom;

@end

@implementation RegisterView_FieldView {
    NSString *_title;
    NSString *_placeholder;
}

- (instancetype)initWithTitle:(NSString *)title placeholder:(NSString *)placeholder {
    _title = title;
    _placeholder = placeholder;
    self = [super init];
    return self;
}

- (void)configSelf {
    self.fp_backgroundColor([UIColor whiteColor]);
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(WINDOW_WIDTH));
        make.height.equalTo(@(RPX(49)));
    }];
}

- (void)allocateComponents {
    self.fp_addSubview(self.lineTop=[[UIView alloc]init]);
    [self.lineTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self);
        make.height.equalTo(@(1));
    }];
    
    self.fp_addSubview(self.titleLabel=[[UILabel alloc]init]);
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(RPX(15));
    }];
    
    self.fp_addSubview(self.textField=[[UITextField alloc]init]);
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(RPX(100));
        make.right.equalTo(self).offset(RPX(-15));
    }];
    
    self.fp_addSubview(self.lineBottom=[[UIView alloc]init]);
    [self.lineBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(self);
        make.height.equalTo(@(1));
    }];
}

- (void)configComponents {
    self.lineTop.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
    
    self.titleLabel.fp_font(RPXFont(15)).fp_text(_title);
    
    self.textField.placeholder = _placeholder;
    self.textField.font = RPXFont(14);
    
    self.lineBottom.fp_backgroundColor(HexadecimalColor(@"#EBEBEB"));
}

- (NSString *)text {
    return self.textField.text;
}

@end
